package com.sample.remote
{
	import com.trg.flex.IEntityDelegate;
	import com.trg.flex.remote.ROCall;
	import com.trg.flex.remote.RemoteCall;
	import com.trg.flex.remote.RemoteServiceLocator;
	import com.trg.flex.search.Search;
	
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.remoting.RemoteObject;
	
	public class EntityDelegate implements IEntityDelegate
	{
		private var remote : RemoteObject;
		
		public function EntityDelegate()
		{
			remote = RemoteServiceLocator.getInstance().getRemoteObject( "entityService" );
		}
		
		public function fetch(className:String, id:Object) : RemoteCall {			
			return new ROCall(remote, 'fetch', className, id);
		}
		public function fetchAll(className:String) : RemoteCall {	
			return new ROCall(remote, 'fetchAll', className);		
		}
		public function create(object:Object) : RemoteCall {
			return new ROCall(remote, 'create', object);
		}
		public function update(object:Object) : RemoteCall {
			return new ROCall(remote, 'update', object);
		}
		public function deleteEntity(object:Object) : RemoteCall {
			return new ROCall(remote, 'deleteEntity', object);
		}
		public function deleteList(list:Array) : RemoteCall {
			return new ROCall(remote, 'deleteList', list);
		}
		public function deleteById(className:String, id:Object) : RemoteCall {			
			return new ROCall(remote, 'deleteById', className, id);
		}
		public function search(search:Search) : RemoteCall {
			return new ROCall(remote, 'search', search);
		}
		public function count(search:Search) : RemoteCall {
			return new ROCall(remote, 'count', search);
		}
		public function searchAndCount(search:Search) : RemoteCall {
			return new ROCall(remote, 'searchAndCount', search);
		}
		public function searchUnique(search:Search) : RemoteCall {
			return new ROCall(remote, 'searchUnique', search);
		}
	}
}